/***************************
 * @description: 启动项目时的配置参数
 * 
 * @update:  2021-04-20  LiLinbin  [创建基础配置]
 * @update:  2021-06-15  LiLinbin  [对接数据,开发环境启用代理'/mock']
 * @update:  2021-12-29  LiLinbin  [重构此文件功能]
 * @update:  2023-02-16  LiLinbin  [添加buildCommon]
 * 
 * 说明:
 * port             开发环境启动项目的端口
 * buildCompDir     build编译组件到指定路径
 ***************************/


//基础配置项
const baseConfig = {
    port: 8101, //开发环境启动端口

    buildCommon: 'new',     //common公共组件包, 'new'新版, 'old'旧版[兼容旧项目]
    cutCommonComp: '全部打包', //打包"common"时，需要去掉哪个版本的组件

    buildCompDir: '//10.1.32.173/VEditor/webroot/components/'  //build编译组件到指定路径
}



//build编译组件到指定路径, 此变量用于nodeJs读取
const buildServerPath = [
    `//10.1.32.173/VEditor/webroot/components/`,    //到线上vCloud平台
    `//10.1.50.46/webroot/components/`,             //到线上vCloud平台
    `//10.1.16.35/VEditor/webroot/components/`,     //到线上vCloud平台
    './dist',
    // `../VEditor/public/components/`                //到VEditor的dev调试代码下
]





const { initMyCli } = require('./mycli.umd.min.js')
const {
    proxyUrl,
    buildProjects,
    externals,
    buildBaseConfig,
    buildInfo
} = initMyCli(process)


const BUILD = (process.env.BUILD || '').trim()
if (BUILD === 'createCompFile') return





// 开发环境下请求数据的代理地址 配置项

const proxyConfig = {
    '/mock': {
        target: proxyUrl.replace(":18650", ":18001"),
        secure: false, // https需要开启此项
        changeOrigin: true, // 开启代理，在本地创建一个虚拟服务端
        // ws: true, // 是否启用websockets
        /* headers: {
            Referer: ''
        }, */
        pathRewrite: {
            '^/mock': '/mock'
        }
    },
    "/upload": {
        target: proxyUrl.replace(":18650", ":18001"),
        secure: false, // https需要开启此项
        changeOrigin: true,
        pathRewrite: {
            '^/upload': '/upload'
        }
    },
    "/ProjectFrame": {
        target: proxyUrl.replace(":18650", ":18001"),
        secure: false, // https需要开启此项
        changeOrigin: true,
        pathRewrite: {
            '^/ProjectFrame': '/ProjectFrame'
        }
    },
    "/mapService": {
        target: 'http://10.1.32.175/',
        secure: false, // https需要开启此项
        changeOrigin: true,
        pathRewrite: {
            '^/mapService': '/mapService'
        }
    },
    //superSource项目接口服务
    '/QPROXY': {
        target: proxyUrl,
        secure: false,
        changeOrigin: true,
        pathRewrite: {
            '^/QPROXY': '/QPROXY'
        }
    }
}









const myConfig = {
    baseConfig: buildBaseConfig || baseConfig,
    proxyConfig,
    buildProjects,
    externals,
    buildInfo
}



module.exports = myConfig